import config
import requests
from api.login import LoginAPI
class StaffAPI:
    def add_staff(self,add_data,token):
        url=config.BASE_URL + "/api/sys/user"
        header_data={"Authorization":token}
        # add_data={
        #     "username":"jack0709t2",
        #     "mobile":"13111141901",
        #     "timeOfEntry":"2020-07-09",
        #     "formOfEmployment":1,
        #     "workNumber":"10086",
        #     "departmentName":"销售",
        #     "departmentId":"1266699057968001024",
        #     "correctionTime":"2020-07-30T16:00:00.000Z"
        # }
        response=requests.post(url=url,json=add_data,headers=header_data)
        return response
    def update_staff(self,user_id,update_data,token):

        url=config.BASE_URL+"/api/sys/user/{}".format(user_id)
        # update_data={"username":"yanxiaolu"}
        header_data = {"Authorization": token}
        response=requests.put(url=url,json=update_data,headers=header_data)
        return response
    def select_staff(self,user_id,token):
        url=config.BASE_URL+"/api/sys/user/{}".format(user_id)
        header_data = {"Authorization": token}
        response=requests.get(url=url,headers=header_data)
        return response
    def delete_staff(self,user_id,token):
        url=config.BASE_URL+"/api/sys/user/{}".format(user_id)
        header_data = {"Authorization":token}
        response=requests.delete(url=url,headers=header_data)
        return response


# if __name__ == '__main__':
#     print(StaffAPI().add_staff().json())
